// components/zy-popover/zy-popover.js
Component({

    /**
     * 组件的属性列表
     */
    properties: {
        
    },

    /**
     * 组件的初始数据
     */
    data: {
        title: '',
        isShow: false,
        getCls(isShow) {
            let str = ''
            if (isShow) {
                str = str + 'zy-popover--show'
            }
            return str
        },
        left: '',
        top: ''
    },

    /**
     * 组件的方法列表
     */
    methods: {
        open() {
            this.setData({
                isShow: true
            })
        },
        setPos(rectQuery) {
            let left = rectQuery.left;
            let top = rectQuery.top + rectQuery.height
            this.setData({
                left: left + 'px',
                top: top + 'px'
            })
            // console.log(rectQuery);
        },
        toggle(rectQuery) {
            if (this.data.isShow) {
                this.setData({
                    isShow:false,
                    left: '',
                    top: ''
                })
            } else {
                this.setPos(rectQuery);
                this.open()
            }
        }
    }
})